package com.itheima.health.controller.admin;

import com.itheima.health.common.MessageConst;
import com.itheima.health.pojo.dto.SetmealOrderDTO;
import com.itheima.health.pojo.result.Result;
import com.itheima.health.service.ReportService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import com.itheima.health.pojo.result.Result;
import com.itheima.health.pojo.vo.BusinessReportDataVO;
import com.itheima.health.pojo.vo.MemberReportVO;
import com.itheima.health.service.ReportService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;

@Slf4j
@RestController
@RequestMapping("/report")
public class ReportController {
    @Autowired
    private ReportService reportService;

    /**
     * 统计分析-会员数量折线图
     * @return
     */
    @GetMapping("/getMemberReport")
    public Result getMemberReport() {
        log.info("统计分析-会员数量折线图：");
        MemberReportVO memberReportVO = reportService.getMemberReport();
        return new Result(true, MessageConst.GET_SETMEAL_COUNT_REPORT_SUCCESS,memberReportVO);
    }

    /**
     * 统计分析-运营数据统计页面展示
     * @return
     */
    @GetMapping("/getBusinessReportData")
    public Result getBusinessReportData() {
        log.info("统计分析-运营数据统计页面展示：");
        BusinessReportDataVO businessReportDataVO = reportService.getBusinessReportData();
        return new Result(true, MessageConst.GET_SETMEAL_COUNT_REPORT_SUCCESS,businessReportDataVO);
    }

    /**
     * 套餐预约占比统计
     */
    @GetMapping("/getSetmealReport")
    public Result getSetmealReport() {
        log.info("套餐预约占比统计");
        SetmealOrderDTO setmealOrderDTO = reportService.getSetmealReport();
        return new Result(true, MessageConst.GET_SETMEAL_COUNT_REPORT_SUCCESS,setmealOrderDTO);
    }


    /**
     * 统计分析-运营数据统计报表导出
     */
    @GetMapping("/exportBusinessReport")
    public void exportBusinessReport(HttpServletResponse response) {
        log.info("统计分析-运营数据统计报表导出");
        reportService.exportBusinessReport(response);
    }
}
